<!--
  ~
  ~   ~ MIT License
  ~   ~
  ~   ~ Copyright (c) 2021-2022 yangrunkang
  ~   ~
  ~   ~ Author: yangrunkang
  ~   ~ Email: yangrunkang53@gmail.com
  ~   ~
  ~   ~ Permission is hereby granted, free of charge, to any person obtaining a copy
  ~   ~ of this software and associated documentation files (the "Software"), to deal
  ~   ~ in the Software without restriction, including without limitation the rights
  ~   ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  ~   ~ copies of the Software, and to permit persons to whom the Software is
  ~   ~ furnished to do so, subject to the following conditions:
  ~   ~
  ~   ~ The above copyright notice and this permission notice shall be included in all
  ~   ~ copies or substantial portions of the Software.
  ~   ~
  ~   ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  ~   ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  ~   ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  ~   ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  ~   ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  ~   ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  ~   ~ SOFTWARE.
  ~
  -->

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      th:replace="index">
<!--css-->
<link th:fragment="css" type="text/css" rel="stylesheet" th:href="${ossStatic} + @{/css/editor/editor.css}"/>
<link th:fragment="css" type="text/css" rel="stylesheet" th:href="${ossStatic} + @{/css/common/img.css}"/>
<!--脚本-->
<script th:fragment="js" type="text/javascript" th:src="${ossStatic} + @{/js/editor/editor.js}"></script>
<link th:fragment="css" type="text/css" rel="stylesheet"
      th:href="'/plugins/cherry/cherry-markdown.min.css?v='+${staticSourceVersion}"/>
<script th:fragment="js" type="text/javascript"
        th:src="${ossStatic} +@{/plugins/cherry/cherry-markdown.min.js}+'?v='+${staticSourceVersion}"></script>
<!--内容-->
<div th:fragment="content">
    <div class="container">
        <div class="alert alert-primary alert-dismissible fade show mb-2" role="alert"
             th:if="${hasContentCanToRestore}">
            如需将编辑器中的内容恢复至最近一次正式发布的内容,
            <span onclick="cleanDraftAndReload()" style="cursor: pointer" class="fw-bold">请点我
            <i class="bi bi-arrow-left-circle"></i>
        </span>
            <button type="button" class="btn btn-close rounded-3 bg-gradient-close" data-bs-dismiss="alert"
                    aria-label="Close"></button>
        </div>
        <div class="row g-2">
            <div class="col-lg-9 mb-2">
                <div class="card border-0 rounded-3 p-2 mb-2 d-block text-secondary"
                     th:if="${editorIndexDto.createContentDesc.tips != null}">
                    [[${editorIndexDto.createContentDesc.tips}]]
                </div>
                <div class="card border-0 rounded-3 p-2">
                    <form>
                        <div class="mb-3 ui form field">
                            <label for="title" class="text-black-50">标题</label>
                            <div>
                                <textarea type="text" class="fluid" id="title" rows="2"
                                          placeholder="如果内容标题可以描述清楚,内容可以不用填写"
                                          th:text="${editorIndexDto?.contentEnhance?.content?.title}"
                                ></textarea>
                            </div>
                        </div>
                        <div class="mb-3" th:if="!${#lists.isEmpty(editorIndexDto.tagEnhanceList)}">
                            <label for="title" class="text-black-50">标签</label>
                            <select id="cv_selectpicker" class="form-select">
                                <option value="">无</option>
                                <option th:each="menu : ${editorIndexDto.tagEnhanceList}"
                                        th:value="${menu.tag.tagId}"
                                        th:selected="${#strings.contains(editorIndexDto?.contentEnhance?.content?.tagIds,menu.tag.tagId) or editorIndexDto?.createTag == menu.tag.tagId}"
                                >
                                    [[${menu.tag.tagName}]]
                                </option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <div th:replace="fragments/comment::loading_editor(false)"></div>
                            <!--编辑器-->
                            <input type="hidden" id="md_value"
                                   th:value="${editorIndexDto?.contentEnhance?.contentExtendEnhance?.contentExtend?.markdownContent}"/>
                            <input type="hidden" id="html_value"
                                   th:value="${editorIndexDto?.contentEnhance?.contentExtendEnhance?.contentExtend?.detailContent}"/>
                            <div id="vcr_editor"
                                 style="overflow:hidden">
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="col-lg-3">
                <div class="card border-0 rounded-3 p-2">
                    <div class="border-bottom mb-1">控制面板</div>
                    <!--未登录提示-->
                    <div th:include="fragments/index::user_not_login"></div>
                    <!--全局异常提示-->
                    <div class="card border-0 border-danger mb-3" th:if="${cvException != null}">
                        <div class="card border-0-header">
                            <h3 class="card border-0-title">出错了~</h3>
                        </div>
                        <div class="card border-0-title" th:text="${cvException}"></div>
                    </div>
                    <div>
                        <button th:if="${editorIndexDto?.contentEnhance?.content?.status.name() == 'NORMAL' or editorIndexDto?.contentEnhance?.content?.status.name() == 'DRAFT'}" type="button" class="ui primary button" onclick="saveOrUpdateContent()">[[${edit_btn_text}]]</button>
                        <button th:if="${editorIndexDto?.contentEnhance?.content?.status.name() == 'ONLY_SELF_CAN_SEE'}" type="button" class="ui primary button" onclick="saveOrUpdateContent()">编辑完成</button>
                        <button type="button" class="ui button"
                                onclick="draftSave()">暂存
                        </button>
                    </div>
                </div>
                <!--转载或者原创-->
                <div class="card border-0 rounded-3 p-2 my-2">
                    <div class="ui form">
                        <div class="inline fields mb-1">
                            <div class="field">
                                <div class="ui radio checkbox">
                                    <input type="radio" name="original" value="ORIGIN" th:checked="${editorIndexDto?.contentEnhance?.content?.originType.name() != 'NONE_ORIGIN'}?'checked'" class="align-self-center original_radio">
                                    <label>原创</label>
                                </div>
                            </div>
                            <div class="field">
                                <div class="ui radio checkbox">
                                    <input type="radio" name="original" value="NONE_ORIGIN" th:checked="${editorIndexDto?.contentEnhance?.content?.originType.name() == 'NONE_ORIGIN'}?'checked'" class="align-self-center original_radio">
                                    <label>转载</label>
                                </div>
                            </div>
                        </div>
                        <div class="original ui input"
                             th:style="${editorIndexDto?.contentEnhance?.content?.originType.name()} == 'ORIGIN' ? 'display: block':'display: none'">
                            <div class="small mt-1">
                                原创作品将采用<a class="cv-link fw-bold" target="_blank"
                                          href="https://creativecommons.org/licenses/by-nc-nd/4.0/deed.zh">《署名-非商业性使用-禁止演绎4.0
                                国际》</a>许可协议进行发布
                            </div>
                        </div>
                        <div class="none_original"
                             th:style="${editorIndexDto?.contentEnhance?.content?.originType.name()} == 'NONE_ORIGIN' ? 'display: block':'display: none'">
                            <div class="mb-0">
                                <textarea id="none_original_link" rows="2"
                                          placeholder="转载地址" th:text="${editorIndexDto?.contentEnhance?.content?.noneOriginLink}"
                                ></textarea>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="card border-0 rounded-3 p-2 auto-save-card border-0"
                     style="display: none">
                    <!--提示自动保存-->
                    <div class="fw-light text-black-50 border-bottom mb-2">文章自动保存提示</div>
                    <div class="auto-save"
                         style="background-color: #4285f4;padding: 6px;border-radius: 5px;color: #ffffff;font-size: 13px;display: none"></div>
                </div>
                <div class="card border-0 rounded-3 p-2 my-2">
                    <div class="border-bottom mb-2">友请提示</div>
                    <div class="small">1. 如果内容标题可以描述清楚,内容可以不用填写</div>
                </div>
                <div th:replace="fragments/editor::upupor-editor-progress"></div>
                <div class="card border-0 rounded-3 p-2 my-2"
                     th:include="fragments/index::apply_tag"></div>
                <div class="card border-0 rounded-3 p-2 my-2"
                     th:include="fragments/common::markdown"></div>
                <div class=" card border-0 rounded-3 p-2 my-2">
                    <div class="ui form">
                        <div class="field">
                            <label class="text-black-50 fw-light">编辑原因</label>
                            <textarea id="edit_reason" rows="2"
                                      placeholder="编辑原因" th:text="${editorIndexDto.contentEnhance?.contentEditReasonEnhance?.contentEditReason?.reason}"
                            ></textarea>
                        </div>
                    </div>
                </div>
                <div>
                    <!--隐藏域-->
                    <input type="hidden" class="hide-content-content-id"
                           th:value="${editorIndexDto?.contentEnhance?.content?.contentId}"/>
                    <input type="hidden" class="hide-content-user-id"
                           th:value="${editorIndexDto?.contentEnhance?.content?.userId}"/>
                    <input type="hidden" class="hidden-pre-content-id" th:value="${pre_content_id}"/>
                    <input type="hidden" class="has-content-can-to-restore" th:value="${hasContentCanToRestore}"/>
                </div>
            </div>
        </div>
    </div>
</div>
</html>
